package com.zareal.ymcc.feign.fallback;

import com.zareal.ymcc.feign.CourseServiceFeignClient;
import com.zareal.ymcc.result.JSONResult;
import feign.hystrix.FallbackFactory;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;

@Component
@Slf4j
public class CourseServiceFeignClientFallbackFactory implements FallbackFactory<CourseServiceFeignClient> {
    @Override
    public CourseServiceFeignClient create(Throwable throwable) {
        throwable.printStackTrace();
        log.info("订单调用课程接口获取课程信息失败");
        return new CourseServiceFeignClient() {

            @Override
            public JSONResult getInfo(String courseIds) {
                return JSONResult.error("订单调用课程接口获取课程信息失败","90000");
            }

            /**
             * 获取对象
             *
             * @param id
             */
            @Override
            public JSONResult get(Long id) {
                return JSONResult.error("获取课程信息失败","90000");

            }
        };
    }
}
